<template>
  <div class="redirect-page">
    <div class="redirect-page-status">
      <div
        v-if="isSignSuccess === 1"
        class="sign-contract-success"
      >
        <div class="icon">
          <image src="../../static/images/signing_success.png" />
        </div>
        <div class="tip">
          恭喜，签约成功！
        </div>
      </div>
      <div
        v-else-if="isSignSuccess === 0"
        class="sign-contract-fail"
      >
        <div class="icon">
          <image src="../../static/images/signing_fail.png" />
        </div>
        <div class="tip">
          签约失败！
        </div>
      </div>
    </div>
    <div
      class="back-app"
      @tap="onBackApp"
    >
      返回App
    </div>
  </div>
</template>

<script setup>
const isSignSuccess = ref(-1) // 是否签约成功 0:失败 1:成功
onLoad((options) => {
  // 获取页面返回参数，并设置页面标题
  if (options.isSignSuccess && (Number(options.isSignSuccess) || Number(options.isSignSuccess) === 0)) {
    // 判断是否为签约页面返回
    isSignSuccess.value = Number(options.isSignSuccess)
    uni.setNavigationBarTitle({
      title: '提现签约'
    })
  }
})
const onBackApp = () => {
  const platform = uni.getSystemInfoSync().platform
  if (platform === 'ios') {
    window.location.href = `cn.net.${import.meta.env.VITE_APP_URL_SCHEMES}://app`
  }
  if (platform === 'android') {
    window.location.href = `${import.meta.env.VITE_APP_URL_SCHEMES}://app`
  }
}
</script>

<style lang="scss" scoped>
@use "./redirect.scss";
</style>
